package cn.tedu.egmybatis2.mapper;

import cn.tedu.egmybatis2.pojo.entity.Orders;
import cn.tedu.egmybatis2.pojo.vo.OrdersVO1;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface OrderMapper {
    //第1题：添加一个订单：insertOrders
    @Insert("INSERT INTO orders(state,amount,created) VALUES (#{state},#{amount},#{created})")
    int insertOrders(Orders orders);

    //第2题：查询所有订单：selectAll 全列查询
    @Select("SELECT id,state,amount,created FROM orders")
    List<Orders> selectAll();

    //第3题：通过id查询1个订单：selectOne 只查询订单状态和金额
    @Select("SELECT state,amount FROM orders WHERE id = #{id}")
    OrdersVO1 selectOne(int id);

    //第4题：通过一个id删除订单：deleteById
    @Delete("DELETE FROM orders WHERE id = #{id}")
    int deleteById(int id);
}
